﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms.DataVisualization.Charting;

namespace HeThongDoDien.Helper
{
    public static class GraphHelper
    {
        public static void Draw(this Series series, DataTable data)
        {
            /// series.Points.AddXY(
        }

        public static void FormatNormalize(this Chart chart)
        {
            chart.GetToolTipText += new EventHandler<ToolTipEventArgs>(chart_GetToolTipText);
        }

        private static void chart_GetToolTipText(object sender, ToolTipEventArgs e)
        {
            // Check selected chart element and set tooltip text
            if (e.HitTestResult.ChartElementType == ChartElementType.DataPoint)
            {
                var i = e.HitTestResult.PointIndex;
                var dp = e.HitTestResult.Series.Points[i];
                e.Text = string.Format("{0:F1}, {1:F1}", dp.XValue, dp.YValues[0]);
            }
        }

        private static void EnableZoomView(this Chart chart)
        {
            chart.ChartAreas[0].CursorX.IsUserEnabled = true;
            chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            chart.ChartAreas[0].CursorY.IsUserEnabled = true;
            chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
        }
    }
}
